const express = require('express');
const app = express();
const port = 8080;
// 引入数据库文件
const mysql = require('mysql');
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'five'
});
connection.connect();
app.get('/resImg', (req, res) => {
    connection.query(`select * from resimg;`, (err, rows, fields) => {
        res.send(rows)
    })

})
app.get('/hotCity', (req, res) => {
    connection.query(`select * from visaMain;`, (err, rows, fields) => {
        res.send(rows)
    })
})
app.get('/otherCity', (req, res) => {
    connection.query(`select * from visaOther;`, (err, rows, fields) => {
        res.send(rows)
    })
})
app.get('/mangkok', (req, res) => {
    connection.query(`select * from mangkok;`, (err, rows, fields) => {
        res.send(rows)
        // console.log(rows);
    })
})
app.get('/tokyo', (req, res) => {
    connection.query(`select * from tokyo;`, (err, rows, fields) => {
        res.send(rows)
        // console.log(rows);
    })
})
app.get('/lowPrice', (req, res) => {
    let city = req.query.city
    connection.query(`select * from ${city} order by nprice asc;  `, (err, rows, fields) => {
        res.send(rows)
        // console.log(rows);
    })
})
app.listen(port, () => {
    console.log('连接成功')
})